package cn.jingzhuan.fm.di.component

import cn.jingzhuan.element.demo.view.fragment.FMAudioListFragment
import cn.jingzhuan.fm.di.scope.FragmentScope
import cn.jingzhuan.fm.mvp.contract.FMAudioListContract
import dagger.Module
import dagger.Provides
import dagger.Subcomponent
import dagger.android.AndroidInjector

@FragmentScope
@Subcomponent(modules = [(FMAudioListModule::class)])
interface FMAudioListComponent  : AndroidInjector<FMAudioListFragment> {

    @Subcomponent.Builder
    abstract class Builder : AndroidInjector.Builder<FMAudioListFragment>() {
        abstract fun newModule(module : FMAudioListModule):Builder

        override fun seedInstance(instance: FMAudioListFragment) {
            newModule(FMAudioListModule(instance))
        }
    }
}

@Module
class FMAudioListModule(val mView: FMAudioListContract.View) {
    @Provides
    fun getView() = mView
}
